<div ng-controller='AuthManagerIndex' class='right-cont'>
    <div class='title'>
        <i class='fa fa-list-ul'></i>权限管理
    </div>

    <div class='box-cont'>
        <div>
            <button class='btn btn-primary btn-sm btn-w-sm btn-shadow' data-toggle='modal' data-target='.modal-add-group'>
                添加
            </button>
            <button class='btn btn-success btn-sm btn-w-sm btn-shadow' ng-click='batch_change_status("resumegroup")'>
                启用
            </button>
            <button class='btn btn-warning btn-sm btn-w-sm btn-shadow' ng-click='batch_change_status("forbidgroup")'>
                禁用
            </button>
            <button class='btn btn-danger btn-sm btn-w-sm btn-shadow' ng-click='batch_change_status("deletegroup")'>
                删除
            </button>
        </div>

        <hr class='hr-sm'>

        <table class='table table-list wrap-checkbox'>
            <tr>
                <td widtd='40'><input type='checkbox' class='check-all'></td>
                <td>用户组</td>
                <td>描述</td>
                <td>状态</td>
                <td>操作</td>
            </tr>
            <tr ng-repeat='auth in auths' ng-if='auth.status != -1'>
                <td><input type='checkbox' name='id[]' value='{{auth.id}}'></td>
                <td><a ng-click='detail(auth.id)' href='javascript:void(0)'>{{auth.title}}</a></td>
                <td>{{auth.description}}</td>
                <td>
                    <span class='label label-sm label-warning' ng-if='auth.status == 0'>
                        {{auth.status_text}}
                    </span>
                    <span class='label label-sm label-success' ng-if='auth.status == 1'>
                        {{auth.status_text}}
                    </span>
                </td>
                <td>
                    <button class='btn btn-primary btn-xs btn-w-xs' ng-click='detail_group_auths(auth.id)'>
                        授权
                    </button>

                    <span ng-if='auth.status == 1'>
                        <button class='btn btn-warning btn-xs btn-w-xs' 
                            ng-click='change_status(auth.id, "forbidgroup")'>
                            禁用
                        </button>
                    </span>
                    <span ng-if='auth.status == 0'>
                        <button class='btn btn-success btn-xs btn-w-xs' 
                            ng-click='change_status(auth.id, "resumegroup")'>
                            启用
                        </button>
                    </span>
                    <button class='btn btn-danger btn-xs btn-w-xs' 
                        ng-click='change_status(auth.id, "deletegroup")'>
                        删除
                    </button>
                </td>
            </tr>
        </table>

        <div class='box-page' ng-bind-html='pages'></div>
    </div>

    <div class='box-page' ng-bind-html='pages'></div>

    <!-- 组权限分配 模态窗-->
    <div class='modal fade modal-group-auth'>
        <div class='modal-dialog' style='width:60%; min-width:600px;'>
            <div class='modal-content'>
                <div class='modal-header'>
                    组权限分配
                    <a class='close' data-dismiss='modal'>&times;</a>
                </div>
                <div class='modal-body'>
                    <div class='auth-title recursive' ng-repeat='auth_title in mode_list'>
                        <div class='title'>
                            <input type='checkbox' value='{{auth_title.auth_id}}'>
                            {{auth_title.title}}
                        </div>
                        <div class='auth-name recursive' ng-repeat='auth in auth_title.child'>
                            <div class='title'>
                                <input type='checkbox' value='{{auth.auth_id}}'>{{auth.title}}
                            </div>
                            <div class='auth-child recursive'>
                                <span ng-repeat='auth_child in auth.operator'>
                                    <input type='checkbox' value='{{auth_child.auth_id}}'>{{auth_child.title}}
                                </span>
                            </div>
                        </div>
                    </div>
                    
                </div>

                <div class='modal-footer'>
                    <button class='btn btn-primary btn-sm btn-w-md' ng-click='auths_save()'>确定</button>
                    <button class='btn btn-default btn-sm btn-w-md' data-dismiss='modal'>取消</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 组信息编辑 模态窗-->
    <div class='modal fade modal-list-form modal-edit-group'>
        <div class='modal-dialog'>
            <div class='modal-content' align='center'>
                <div class='modal-header'>
                    权限组编辑
                    <a class='close' data-dismiss='modal'>&times;</a>
                </div>
                <div class='modal-body'>
                    <table class='table-form'>
                        <tr>
                            <td class='td-label'>组名称:</td>
                            <td><input type='text' class='form-control input-sm' ng-model='title'></td>
                        </tr>
                        <tr>
                            <td class='td-label'>组描述:</td>
                            <td><input type='text' class='form-control input-sm' ng-model='description'></td>
                        </tr>
                    </table>
                </div>
                <div class='modal-footer'>
                    <button class='btn btn-primary btn-sm btn-w-sm' ng-click='save()'>保存</button>
                    <button class='btn btn-sm btn-w-sm' data-dismiss='modal'>取消</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 添加组 模态窗-->
    <div class='modal fade modal-list-form modal-add-group'>
        <div class='modal-dialog'>
            <div class='modal-content' align='center'>
                <div class='modal-header'>
                    权限组添加
                    <a class='close' data-dismiss='modal'>&times;</a>
                </div>
                <div class='modal-body'>
                    <table class='table-form'>
                        <tr>
                            <td class='td-label'>组名称:</td>
                            <td><input type='text' class='form-control input-sm' ng-model='aTitle'></td>
                        </tr>
                        <tr>
                            <td class='td-label'>组描述:</td>
                            <td><input type='text' class='form-control input-sm' ng-model='aDescription'></td>
                        </tr>
                    </table>
                </div>
                <div class='modal-footer'>
                    <button class='btn btn-primary btn-sm btn-w-sm' ng-click='add_group()'>确认</button>
                    <button class='btn btn-default btn-sm btn-w-sm' data-dismiss='modal'>取消</button>
                </div>
            </div>
        </div>
    </div>
</div>